package com.lanchetech.admin.controller;

import com.lanchetech.admin.service.BlogService;
import com.lanchetech.bean.request.BlogPageReq;
import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.request.TagCategoryPageReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.BaseResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.BlogDetailVO;
import com.lanchetech.bean.vo.BlogVO;
import com.lanchetech.entity.TagCategory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "博文接口", tags = "博文接口")
@RequestMapping("/api/blog")
@RestController
public class BlogController {

    @Autowired
    BlogService blogService;

    @ApiOperation("审核博文")
    @GetMapping("/auditBlog")
    public BaseResp auditBlog(@RequestParam("id") Long id,@RequestParam("auditStatus") Byte auditStatus,@RequestParam(name = "remark",required = false) String remark) {
        return blogService.auditBlog(id,auditStatus,remark);
    }

    @ApiOperation("获取博文分页")
    @PostMapping("/getBlogPage")
    public ResultData<BasePageResp<BlogVO>> getBlogPage(@RequestBody BlogPageReq req) {
        return blogService.getBlogPage(req);
    }

    @ApiOperation("获取博文详情")
    @GetMapping("/getBlogDetail")
    public ResultData<BlogDetailVO> getBlogDetail(@RequestParam("id") Long id) {
        return blogService.getBlogDetail(id);
    }

    @ApiOperation("编辑标签类目")
    @PostMapping("/auditTagCategory")
    public BaseResp auditTagCategory(@RequestBody TagCategory req) {
        return blogService.auditTagCategory(req);
    }

    @ApiOperation("获取标签类目分页")
    @PostMapping("/getTagCategoryPage")
    public ResultData<BasePageResp<TagCategory>> getTagCategoryPage(@RequestBody TagCategoryPageReq req) {
        return blogService.getTagCategoryPage(req);
    }

    @ApiOperation("删除标签类目")
    @GetMapping("/deleteTagCategory")
    public BaseResp deleteTagCategory(@RequestParam("id") Long id) {
        return blogService.deleteTagCategory(id);
    }

    @ApiOperation("标签详情")
    @GetMapping("/getTagCategoryDetail")
    public ResultData<TagCategory> getTagCategoryDetail(@RequestParam("id") Long id) {
        return blogService.getTagCategoryDetail(id);
    }

    @ApiOperation("获取标签类目")
    @PostMapping("/getTagCategoryList")
    public ResultData<List<TagCategory>> getTagCategoryList(@RequestBody TagCategory req) {
        return blogService.getTagCategoryList(req);
    }
}
